
package sample.plugin;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

/**
 * 执行HTTP查询的Mojo
 */
@Mojo(name = "query",  defaultPhase = LifecyclePhase.TEST)
public class QueryMojo extends AbstractMojo {

    @Parameter(property = "url", required = true)
    private String url;

    @Parameter(property = "timeout", defaultValue = "5000")
    private int timeout;

    private String option0;
    private String option1;

    @Parameter(property = "options")
    public void setOptions(String[] options) {
        // we can do something more with provided parameter
        this.option0 = options[0];
        this.option1 = options[1];
    }


    public void execute() throws MojoExecutionException {
        getLog().info("Starting query to URL: " + url+" options: ["+option0+","+option1+"]  timeout: "+timeout);
    }
}